import pandas as pd
import numpy as np

# ① 创建DataFrame
data = {
    'year': [2019, 2020, np.nan, 2020, 2022],
    'month': [3, np.nan, 6, 9, 12],
    'day': [4, 2, 21, 2, 15]
}
df = pd.DataFrame(data)

# ② 填充缺失值
df['year'].fillna(2021, inplace=True)
df['month'].fillna(9, inplace=True)

# 转换为整数类型（避免出现浮点年/月）
df = df.astype({'year': 'int', 'month': 'int'})

# ③ 删除重复行
df = df.drop_duplicates()

# ④ 组合时间列
df['date'] = pd.to_datetime(df[['year', 'month', 'day']])

# 打印结果
print("处理后的DataFrame：")
print(df)